//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//********************************************************* 

using System;
using System.Collections.ObjectModel;
using System.Drawing;
using Microsoft.Office.Interop.Word;

namespace Microsoft.TridentWordAddIn.Common
{
    /// <summary>
    /// This interface is implemented by the Word Add-in and provides 
    /// components using the interface to react to certain word and for 
    /// accessing the information related to Images in the document
    /// </summary>
    public interface IThisAddInPackageHost
    {
        #region Events

        /// <summary>
        /// Occurs when [on add in shutdown].
        /// </summary>
        event EventHandler<EventArgs> OnAddInShutdown;

        /// <summary>
        /// An event that fires when a document is saved by the user. This event is needed
        /// to write in-memory data (representing custom XML parts) to the word document
        /// </summary>
        event EventHandler<DocumentSaveEventArgs> DocumentSave;

        /// <summary>
        /// An event that fires when a document is about to be closed by the user. 
        /// </summary>
        event EventHandler<CancelCloseEventArgs> DocumentClose;

        /// <summary>
        /// An event that fires when a document is opened by the user. 
        /// </summary>
        event EventHandler DocumentOpen;

        /// <summary>
        /// This event is fired whenever the user selects an image in the Word application.
        /// </summary>
        event EventHandler<PictureSelectionChangedEventArgs> OnPictureSelectionChanged;

        /// <summary>
        /// Occurs when [document activated].
        /// </summary>
        event EventHandler DocumentActivated;

        #endregion

        #region Properties

        /// <summary>
        /// Gets the active document key.
        /// </summary>
        /// <value>The active document key.</value>
        int ActiveDocumentKey
        {
            get;
        }

        /// <summary>
        /// Gets the document count.
        /// </summary>
        /// <value>The document count.</value>
        int DocumentsCount { get; }

        /// <summary>
        /// Gets the document range.
        /// </summary>
        /// <value>The document range.</value>
        PictureRange DocumentRange { get; }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is document dirty.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is document dirty; otherwise, <c>false</c>.
        /// </value>
        bool IsDocumentDirty { get; set; }

        #endregion

        #region Methods

        /// <summary>
        /// Gets the selected picture.
        /// </summary>
        /// <returns>DocumentPicture</returns>
        DocumentPicture GetSelectedPicture();

        /// <summary>
        /// Gets all pictures.
        /// </summary>
        /// <param name="documentKey">The document key.</param>
        /// <returns>ReadOnlyCollection of type DocumentPicture</returns>
        ReadOnlyCollection<DocumentPicture> GetAllPictures(int documentKey);

        /// <summary>
        /// Determines whether [is document protected] [the specified document key].
        /// </summary>
        /// <param name="documentKey">The document key.</param>
        /// <returns>
        /// 	<c>true</c> if [is document protected] [the specified document key]; otherwise, <c>false</c>.
        /// </returns>
        bool IsDocumentProtected(int documentKey);

        /// <summary>
        /// Insert an image at the current cursor location in the host
        /// </summary>
        /// <param name="documentKey">The document key.</param>
        /// <param name="range">The document range at which image is to be inserted.</param>
        /// <param name="image">The image to be inserted.</param>
        /// <returns>PictureRange</returns>
        PictureRange InsertPicture(int documentKey, PictureRange range, Image image);

        /// <summary>
        /// Protects the document.
        /// </summary>
        /// <param name="password">The password.</param>
        /// <returns>bool</returns>
        bool ProtectDocument(string password);

        /// <summary>
        /// Unprotects the document.
        /// </summary>
        /// <param name="password">The password.</param>
        /// <returns>bool</returns>
        bool UnprotectDocument(string password);

        /// <summary>
        /// Models the exists.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>bool</returns>
        bool ModelExists(int key);

        /// <summary>
        /// Gets the document by document key.
        /// </summary>
        /// <param name="documentKey">The document key.</param>
        /// <returns>Document</returns>
        Document GetDocumentByDocumentKey(int documentKey);

        /// <summary>
        /// Gets the selected image.
        /// </summary>
        /// <param name="documentKey">The document key.</param>
        /// <param name="pictureKey">The picture key.</param>
        /// <returns>Image</returns>
        Image GetSelectedPicture(int documentKey, string pictureKey);

        /// <summary>
        /// Gets the selected picture.
        /// </summary>
        /// <param name="documentKey">The document key.</param>
        /// <param name="range">The range.</param>
        /// <param name="isTridentLink">if set to <c>true</c> [is trident link].</param>
        /// <returns>DocumentPicture</returns>
        DocumentPicture GetSelectedPicture(int documentKey, PictureRange range, bool isTridentLink);

        /// <summary>
        /// Sets the selected image.
        /// </summary>
        /// <param name="documentKey">The document key.</param>
        /// <param name="pictureKey">The picture key.</param>
        void SelectPicture(int documentKey, string pictureKey);

        /// <summary>
        /// Adds the appendix entry.
        /// </summary>
        /// <param name="appendixResult">The appendix result.</param>
        void AddAppendixEntry(AppendixResult appendixResult);

        /// <summary>
        /// Deletes the image.
        /// </summary>
        /// <param name="documentKey">The document key.</param>
        /// <param name="pictureKey">The picture key.</param>
        void DeleteImage(int documentKey, string pictureKey);

        #endregion
    }
}
